﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Criterion;
using ShopSpace.Core.Query;

namespace ShopSpace.Core.Specification.Impl
{
	internal class PersonByUsername : CompositeSpecification<Person>
	{
		public string Username
		{
			get;
			set;
		}

		public int PortalId
		{
			get;
			set;
		}

		public override bool IsSatisfiedBy(Person instance)
		{
			return new PersonUsernameSpecification(this.Username)
				.And(new PersonPortalIdSpecification(this.PortalId))
				.IsSatisfiedBy(instance);
		}

		public override QueryBuilder<Person> AsQueryBuilder()
		{
			return new PersonUsernameSpecification(this.Username)
				.And(new PersonPortalIdSpecification(this.PortalId))
				.AsQueryBuilder();
		}
	}
}